define(['amap'],function () {



    var self,
        app = win.app,
        vueData = {
            tableData: [],
            count: 0,
            limit: 10,
            keyword: ''
        }
    ;




    app.newModule({
        init: function () {
            console.log("lifecycle:init()")
            self = this;
            self._super({
                _tag: 'common_open_map'
            }, win);
        },


        _call:function (obj) {

            //使用方式
            // var pathStr = '{lng: 119.291112, lat: 26.078982}, {lng: 119.290886, lat: 26.078153}, {lng: 119.292067, lat: 26.078278}, {lng: 119.293472, lat: 26.078972}, {lng: 119.293064, lat: 26.08008}, {lng: 119.292367, lat: 26.080013}, {lng: 119.29094, lat: 26.079618}, {lng: 119.291112, lat: 26.078943}, {lng: 119.291133, lat: 26.078943}';
            // var pathStr = '{lng: 118.818214, lat: 31.932064}, {lng: 118.818428, lat: 31.928495}, {lng: 118.822795, lat: 31.929515}, {lng: 118.822162, lat: 31.932319}, {lng: 118.818235, lat: 31.932037}';
            // var pathStr = '{lng: 119.292399, lat: 26.085035}, {lng: 119.293579, lat: 26.081373}, {lng: 119.290983, lat: 26.080718}, {lng: 119.28933, lat: 26.084669}, {lng: 119.292399, lat: 26.085035}, {lng: 119.29242, lat: 26.084996}';
            // self._openTplFull({
            //     tag: 'common_open_map',
            //     tagData: {
            //         pathStr:pathStr
            //     },
            //     index: 2,
            //     openOpts: {
            //         title: '高德地图',
            //         maxmin: true
            //     }
            // });

            console.log("lifecycle:_call()")
            console.log(obj);

            var pathStr = obj.pathStr;
            var pathList = [];
            // var path = JSON.parse(pathStr);
            // console.log(path);
            var bca001 = (pathStr.replaceAll("}, ", "};").split(";"));
            // console.log(bca001s);
            bca001.forEach(function (value) {
                var pathObj=JSON.parse(value.replaceAll(": ", ":\"").replace(", ", "\",").replace("}", "\"}").replace("lng","\"lng\"").replace("lat","\"lat\""));
                pathList.push(pathObj);
            });
            var map = new AMap.Map("common_open_map", {
                center: [116.400274, 39.905812],
                zoom: 14
            });

            // var path = [
            //     [116.403322, 39.920255],
            //     [116.410703, 39.897555],
            //     [116.402292, 39.892353],
            //     [116.389846, 39.891365]
            // ]
            var path = [];
            pathList.forEach(function (value) {
                var temp=[];
                temp.push(parseFloat(value.lng));
                temp.push(parseFloat(value.lat));
                path.push(temp);
            })
            console.log(path);

            var polygon = new AMap.Polygon({
                path: path,
                strokeColor: "#FF33FF",
                strokeWeight: 6,
                strokeOpacity: 0.2,
                fillOpacity: 0.4,
                fillColor: '#1791fc',
                zIndex: 50,
            })

            map.add(polygon)
            // 缩放地图到合适的视野级别
            map.setFitView([ polygon ])
        },

        _ready: function () {
            console.log("lifecycle:_ready()")
            new Vue({
                el: '#common_open_map',
                data: vueData,
                methods: {
                },
                created: function () {
                    self._setEleIsReady('common_open_map');
                }
            });
        },
        _lazy: function () {
            console.log("lifecycle:_lazy()")
            this._super();
        }
    });



});
